package top.kaoshanji.p1ch06a;

/**
 * 代码清单-p1ch06a-111页a：使用this调用构造器
 * author kaoshanji
 * ^_^
 * create time 2025/3/8 16:09
 */
public class Flower {

    public static void main(String[] args) {
        Flower x = new Flower();
        x.printPetalCount();
    }

    int petalCount = 0;
    String s = "initial value";

    Flower(int petals) {
        petalCount = petals;
        System.out.println("Constructor w/ int arg only, petalCount= " + petalCount);
    }

    Flower(String ss) {
        System.out.println("Constructor w/ String arg only, s = " + ss);
        s = ss;
    }

    Flower(String s, int petals) {
        this(petals);
        this.s = s;
        System.out.println("String & int args");
    }

    Flower() {
        this("hi", 47);
        System.out.println("Zero-argument constructor");
    }

    void printPetalCount() {
        System.out.println("petalCount = " + petalCount + " s = "+ s);
    }


}
